package com.wu.configuration;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName AopConfig
 * @Author xwu36
 * @Date 2019/3/5 15:56
 * @Version 1.0
 * @Description
 **/
@Aspect
@Component
public class AopConfig {
    @Autowired
    HttpServletRequest request;

    @Pointcut("execution(public * com.wu.controller.*.*(..))")
    public void test() {
    }

    @Before("test()")
    public void doBefore(JoinPoint point) {
        System.out.println("请求到达,"+ request.getRequestURI());
    }

    @AfterReturning(returning = "res", pointcut = "test()")
    public void doAfter(Object res) {
        System.out.println("接口返回数据:" + res);
    }

}
